fix: save_extra_cmds only works with single string #375
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found this while implementing the quickfix saving idea in #173
Lib.run_hook_cmds
returns a table of tables (one for reach hook cmd that was run). Insave_extra_cmds
,vim.fn.writefile
expects a table strings and if any of those strings contain newlines, they're translated into nul characters. That means that there was no way to return more than one line from asave_extra_cmds
hook function.To fix, we combine the results across all
save_extra_cmds
hooks into a single table and we now support asave_extra_cmds
hook returning either a string (possibly with newlines) or table. If a hook returns a string then any newlines will be used to split the string into individual line entries in the table passed tovim.fn.writefile
. If a hook returns a table, then each of the values of the table will be added to the table passed tovim.fn.writefile
(the same newline splitting will also happen)Also fix typo in
auto_restore_last_session
config name #377